home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / COMMON.ZIP / 13_SHORT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-28  |  2.7 KB  |  128 lines

  1. #pragma inline
  2.  
  3.  
  4. /*
  5.    draws to the screen directly.
  6.  
  7.    x, y, width, height all in pixels, mode 0x13 ONLY
  8.  
  9.    MAX width and height is 255!!!!!
  10.  
  11.    buffer pointer to a width by height array of bytes that are a bitmap
  12.  
  13.    x, y is position to display at, NO checking done for valid
  14.    co-ords etc...
  15.  
  16.    WIDTH MUST BE EVEN!!!!
  17.  
  18.  
  19. */
  20. /* ---------------------- put_blit() --------------------- March 23,1993 */
  21. void put_blit(FARPTR buffer, short x, short y, short width, short height)
  22. {
  23.    asm   {
  24.          push  ds
  25.          push  di
  26.  
  27.          /* calc start address in vido mem */
  28.          mov   ax, y
  29.          mov   bx, x
  30.          xchg  ah, al
  31.          add   bx, ax
  32.          shr   ax, 1
  33.          shr   ax, 1
  34.          add   bx, ax
  35.  
  36.          /* set up address registers for movsw */
  37.          mov   ax, 0xa000
  38.          mov   es, ax
  39.          mov   di, bx
  40.          lds   si, buffer
  41.  
  42.          /* set up width and adjustment for fast blat */
  43.          mov   dx, width
  44.          shr   dx, 1
  45.          mov   bx, 320
  46.          sub   bx, width
  47.          mov   ax, height
  48.          }
  49.  
  50.          /* blast each line */
  51. l1:
  52.    asm   {
  53.          mov   cx, dx
  54.          rep   movsw
  55.          add   di, bx
  56.          dec   ax
  57.          jnz   l1
  58.  
  59.          /* all done */
  60.          pop   di
  61.          pop   ds
  62.          }   
  63. }
  64.  
  65.  
  66.  
  67. /*
  68.    draws to any buffer that is 320x200 in size
  69.  
  70.    x, y, width, height all in pixels, mode 0x13 ONLY
  71.  
  72.    MAX width and height is 255!!!!!
  73.  
  74.    buffer pointer to a width by height array of bytes that are a bitmap
  75.  
  76.    x, y is position to display at, NO checking done for valid
  77.    co-ords etc...
  78.  
  79.    WIDTH MUST BE EVEN!!!!
  80.  
  81. */
  82. /* ---------------------- put_blit2() --------------------- March 23,1993 */
  83. void put_blit2(FARPTR buffer, short x, short y,
  84.               short width, short height,
  85.               FARPTR dest)
  86. {
  87.    asm   {
  88.          push  ds
  89.          push  di
  90.  
  91.          /* calc start address in vido mem */
  92.          mov   ax, y
  93.          mov   bx, x
  94.          xchg  ah, al
  95.          add   bx, ax
  96.          shr   ax, 1
  97.          shr   ax, 1
  98.          add   bx, ax
  99.  
  100.          /* set up address registers for movsw */
  101.          les   di, dest  // es:di points to start dest
  102.          add   di, bx    // make es:di point to x,y in dest
  103.  
  104.          lds   si, buffer
  105.  
  106.          /* set up width and adjustment for fast blat */
  107.          mov   dx, width
  108.          shr   dx, 1
  109.          mov   bx, 320
  110.          sub   bx, width
  111.          mov   ax, height
  112.          }
  113.  
  114.          /* blast each line */
  115. l1:
  116.    asm   {
  117.          mov   cx, dx
  118.          rep   movsw
  119.          add   di, bx
  120.          dec   ax
  121.          jnz   l1
  122.  
  123.          /* all done */
  124.          pop   di
  125.          pop   ds
  126.          }   
  127. }
  128.